package com.wframe.project.former.dataservices.user;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.frame.database.JBaseService;
import com.frame.database.JServiceFactory;
import com.frame.database.JdataBean;
import com.frame.database.PageResult;

public class UserService extends JBaseService<UserDao>{

	public static UserService getIntance(){
        return JServiceFactory.createJServiceProxy(UserService.class);
    }
	
	public PageResult queryUser(JdataBean parms,int size,int pageno) throws Exception{
		PageResult pr=getDao().queryUser(parms, size, pageno);
		return pr;
	}
	
	public JdataBean getCompanyByUid(String userid) throws Exception{
		return getDao().getCompanyByUid(userid);
	}
	
	public JdataBean getCompany(String id) throws Exception{
		return getDao().getCompany(id);
	}
	public JdataBean getUserByOpenId(String openId) throws Exception{
		 return getDao().getUserByOpenId(openId);
	}
	/**
	 * 查询企业信息
	 * @param userid
	 * @return
	 * @throws Exception
	 */
	public JdataBean getCompanyedByUid(String userid) throws Exception{
		return getDao().getCompanyedByUid(userid);
	}
	public void saveCompany(JdataBean bean) throws Exception{
		getDao().saveCompany(bean);
	}
	public void enabledUser(String userid) throws Exception{
		Map u=new HashMap();
		Map k=new HashMap();
		k.put("id", userid);
		u.put("state", 1);
		getDao().update(u, k);
	}
	public void disabledUser(String userid) throws Exception{
		Map u=new HashMap();
		Map k=new HashMap();
		k.put("id", userid);
		u.put("state", 0);
		getDao().update(u, k);
	}
	public void delUser(String userid) throws Exception{
		Map u=new HashMap();
		Map k=new HashMap();
		k.put("id", userid);
		u.put("state", -1);
		getDao().update(u, k);
	}
	public List<JdataBean> querycCompanyQul(String companyid) throws Exception{
		return  getDao().querycCompanyQul(companyid);
	}
	public void authPass(String userid,String companyid) throws Exception{
		getDao().authUpdateState(companyid,2, "");
		Map u=new HashMap();
		Map k=new HashMap();
		k.put("id", userid);
		u.put("authstate",2);
		getDao().update(u, k);
	}
	public void authFail(String userid,String companyid,String authcon) throws Exception{
		getDao().authUpdateState(companyid,3, authcon);
		Map u=new HashMap();
		Map k=new HashMap();
		k.put("id", userid);
		u.put("authstate",3);
		getDao().update(u, k);
	}
	public PageResult queryAuth(JdataBean parms,int size,int pageno) throws Exception{
		return getDao().queryAuth(parms, size, pageno);
	}
	public PageResult queryUserFeedBack(JdataBean parms,int size,int pageno) throws Exception {
		return getDao().queryUserFeedBack(parms,size,pageno);
	}
	public JdataBean getFeedBackById(String id) throws Exception{
		return getDao().getFeedBackById(id);
	}
	public List<JdataBean> queryPicturesDataid(String dataid) throws Exception{
		return getDao().queryPicturesDataid(dataid);
	}

    public void editUserPassword(String id, String password) throws Exception{
		Map u=new HashMap();
		Map k=new HashMap();
		k.put("id", id);
		u.put("loginpwd", password);
		getDao().update(u, k);
    }

	public PageResult queryUserInfo(JdataBean parms, int size, int pageno) throws Exception {
		PageResult pr = getDao().queryUserInfo(parms, size, pageno);
		return pr;
	}

	public List<JdataBean> getProvince() throws Exception {
		return getDao().getProvince();
	}

	public List<JdataBean> getCity(String pid) throws Exception {
		return getDao().getCity(pid);
	}
}
